package org.gw.ylc.base.exception;

import org.springframework.web.servlet.View;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

public class TextView implements View {

	private String value;

	public TextView() {
	}

	public TextView(String value) {
		super();
		this.value = value;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	@Override
	public String getContentType() {
		return "text/plain";
	}

	@Override
	public void render(Map<String, ?> paramMap, HttpServletRequest paramHttpServletRequest,
			HttpServletResponse response) throws Exception {
		response.addHeader("Cache-Control", "no-store");
		response.setContentType(getContentType());
		response.setCharacterEncoding("utf-8");
		if (value != null){
			response.getWriter().write(value);
		}
	}

}
